home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / Problems Folder / Problem 07 - Graph / Solution.cp < prev    next >
Encoding:
Text File  |  1998-06-15  |  1.7 KB  |  35 lines  |  [TEXT/CWIE]

  1. /*
  2. Problem 07 - Graph
  3.  
  4. procedure GraphInit( var graph: Handle; verrticies: UInt32 );
  5. procedure GraphAddDirectedEdge( graph: Handle; vertex1, vertex2: UInt32 );
  6. procedure GraphFindRoute( graph: Handle; vertex1, vertex2: UInt32; var verticies: Handle );
  7.  
  8. GraphInit creates a new, empty directed graph ready to accept directed edges with verrticies verrticies.  All the graph information must be stored in the real Mac memory manager handle - it will be disposed with DisposeHandle and that must release all memory, so dont store any extra information outside the handle.  Also, you must be able to deal with having multiple graphs instantiated simultaneously.
  9.  
  10. GraphAddDirectedEdge adds a directed edge from vertex1 to vertex2
  11.  
  12. GraphFindRoute find a route from vertex1 to vertex2.  If such a route exists, then verticies is returns as a real Mac handle to an array of UInt32s, the first is vertex1, the last is vertex2.  Each successive vertex must have previously had an edge added with GraphAddDirectedEdge.  If no route exists, return nil for verticies.  No vertex should appear more than once in the verticies handle, except for the case where vertex1 is the same as vertex2, in which case you must find a circular route from vertex1 back to itself and so vertex1 will appear exactly twice, once at the start and once at the end of the verticies handle.
  13. */
  14.  
  15. #include "Solution.h"
  16.  
  17. // Fill in your solution and then submit this folder
  18.  
  19. // Team Name: FILL IN YOUR TEAM NAME!
  20.  
  21. pascal void GraphInit( Handle *graph, UInt32 verticies )
  22. {
  23.     *graph = nil;
  24. }
  25.  
  26. pascal void GraphAddDirectedEdge( Handle graph, UInt32 vertex1, UInt32 vertex2 )
  27. {
  28. }
  29.  
  30. pascal void GraphFindRoute( Handle graph, UInt32 vertex1, UInt32 vertex2, UInt32ArrayHandle *verticies )
  31. {
  32.     *verticies = nil;
  33. }
  34.  
  35.